<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="/css/bootstrap.min.css"/>
    <script type="text/javascript" src="/js/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" src="/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/js/jquery.pagination.js"></script>
    <style type="text/css">
        .list-group-item span {
            color: #428bca
        }
    </style>
</head>
<body>
<div class="container">
    <div class="row" style="margin-top: 30px;">
        <div class="col-md-6">
            <form action="/search" method="get">
                <div class="input-group">
                    <input type="text" name="wd" class="form-control" value="<%= wd %>">
                        <span class="input-group-btn">
                              <button class="btn btn-default" type="submit">
                                  Go!
                              </button>
                           </span>
                </div>
            </form>
        </div>
    </div>
    <div class="row" style="margin-top: 20px;">
        <div class="col-md-12">
            <div class="list-group">
                <% docs.forEach(function (product) { %>
                <a class="list-group-item" href="<%= product.url %>" target="_blank"><%- product.title %></a>
                <% }) %>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <ul class="pagination">
            </ul>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $(".pagination").pagination(<%=numFound%>, {
            "num_edge_entries": 1, //边缘页数
            "num_display_entries": 4, //主体页数
            "callback": pageselectCallback,
            "current_page":<%=page_index%>,
            "items_per_page":<%=page_size%> //每页显示1项
        });
        function pageselectCallback(page_index) {
            var url = "/search?wd=<%=req.query.wd%>&page_size=<%=page_size%>&page_index=" + page_index;
            window.location.href = url;
            return false;
        }
    });
</script>
</body>
</html>